#ifndef SERVER_H
#define SERVER_H

#include "Player.h"
#include "Object.h"

#include <boost/asio.hpp>

// FIXME: use static methods and fields
class Server : public MessageHandler
{
	public:
		static const float		CLIENT_UPDATE_TIME;
	
		Server(void);
		~Server(void);

		virtual void onReceiveControlMessage(ControlMessage *receivedMessage,boost::asio::ip::udp::endpoint senderEndpoint);
		virtual void onReceivePlayerMessage(PlayerMessage *receivedMessage,boost::asio::ip::udp::endpoint senderEndpoint);
		virtual void onReceiveItemMessage(ItemMessage *receivedMessage,boost::asio::ip::udp::endpoint senderEndpoint);

		void				updatePhysics( float dt );
		NxOgre::Scene*		getNxScene();

		std::map<boost::asio::ip::udp::endpoint, Player>						_playerMap;

	private:
		//old
		std::map< int, Player* >							_oldPlayerMap;
		NxOgre::TimeController*								_timeController;
		NxOgre::World*										_world;
		NxOgre::Scene*										_scene;
		
		double												_prevTime, _clientProcessTime;

};

#endif
